
<form id="add-form" class="form-horizontal col-sm-12" role="form" data-toggle="validator" method="POST" action="">
	{:token()}
	<input type="hidden" name="row[id]" value="{$row.id}">
	<div class="form-group">
		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-workorder_number">工单编号:</label>
				<input id="c-workorder_number" data-rule="required" class="form-control" placeholder="工单编号" name="row[workorder_number]" value="{$row.workorder_number}" type="text">
			</div>
		</div>
		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-title">工单标题:</label>
				<input id="c-title" data-rule="required" class="form-control" placeholder="工单标题" name="row[title]" type="text" value="{$row.title}">
			</div>
		</div>

		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-customer_id">客户:</label>
				<input id="c-customer_id" data-rule="required" class="form-control selectpage" name="row[customer_id]"
					   data-source="qingdongams/common/getCustomer" type="text" value="{$row.customer_id}">

			</div>
		</div>
		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-contacts">客户联系人:</label>
				<input id="c-contacts" data-rule="required" class="form-control selectpage" name="row[contacts_id]"
					   data-source="qingdongams/common/getContacts" type="text" value="{$row.contacts_id}">
			</div>
		</div>
		<div class="col-xs-12 col-sm-10">
			<div class="form-group col-sm-10">
				<label for="c-address">所属地区:</label>
				<div class='control-relative'>
					<input id="c-address" class="form-control"  name="row[address]" type="text"
						   value="{$row.address}"/>
				</div>
			</div>
		</div>
		<div class="col-xs-12 col-sm-10">
			<div class="form-group col-sm-10">
				<label>详细地址:</label>
				<textarea class="form-control" rows="3" name="row[desc]"
						  placeholder="详细地址">{$row.desc}</textarea>
			</div>
		</div>

		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-aftermarket">问题类型:</label>

				<select id="c-aftermarket" name="row[aftermarket_type_ids]" multiple="multiple" class="form-control selectpicker">
					{$aftermarket_type}
				</select>
			</div>
		</div>

		<table class="table table-responsive fieldlist" data-name="row[product_part]" data-template="testtpl2" data-tag="tr">
			<tr>
				<td>选择已购产品</td>
				<td></td>
			</tr>
			<tr>
				<td colspan="5"><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 追加</a></td>
			</tr>
			<textarea name="row[product_part]" class="form-control hide" cols="30"
					  rows="5">{$row.product_part|json_encode}</textarea>
		</table>
		<table class="table table-responsive fieldlist" data-name="row[parts]" data-template="parttpl" data-tag="tr">
			<tr>
				<td>需携带配件</td>
				<td>配件数量</td>
				<td></td>
			</tr>
			<tr>
				<td colspan="5"><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 选择配件</a></td>
			</tr>
			<textarea name="row[parts]" class="form-control hide" cols="30" rows="5">{$row.parts|json_encode}</textarea>
		</table>
		<div class="col-xs-12 col-sm-10">
			<div class="form-group col-sm-10">
				<label>情况说明:</label>
				<textarea class="form-control" rows="3" name="row[desc]"
						  placeholder="情况说明">{$row.desc}</textarea>
			</div>
		</div>

		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-start_time">开始时间:</label>
				<input id="c-start_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" placeholder="预约时间"
					   name="row[start_time]" type="text" value="{$row.start_time}">
			</div>
		</div>
		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-appointment_time">预计结束时间:</label>
				<input id="c-appointment_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" placeholder="预计结束时间"
					   name="row[appointment_time]" type="text" value="{$row.appointment_time}" >
			</div>
		</div>
		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label for="c-payment">紧急程度:</label>
				<select id="c-payment" name="row[priority]" class="form-control">
					<option value="一般" {eq name="$row.priority" value="一般"}selected="selected"{/eq} >一般</option>
					<option value="紧急"  {eq name="$row.priority" value="紧急"}selected="selected"{/eq}>紧急</option>
					<option value="非常紧急" {eq name="$row.priority" value="非常紧急"}selected="selected"{/eq} >非常紧急</option>
				</select>
			</div>
		</div>

		<div class="col-xs-12 col-sm-6">
			<div class="form-group col-sm-10">
				<label>过保类型:</label>
				{:build_radios('row[is_over]', ['1'=>__('过保'), '2'=>__('未过保')],$row['is_over'])}
			</div>
		</div>

		<div class="col-xs-12 col-sm-10">
			<div class="form-group col-sm-10">
				<label>计划备注:</label>
				<textarea class="form-control" rows="3" name="row[remarks]"
						  placeholder="计划备注">{$row.remarks}</textarea>
			</div>
		</div>
		<div class="col-xs-12 col-sm-10">
			<div class="form-group col-sm-10">
				<label>附件:</label>
				<div class="input-group">
					<input id="c-files" class="form-control" size="50" name="row[files]"
						   type="text" value="{$row.files}">
					<div class="input-group-addon no-border no-padding">
                        <span><button type="button" id="plupload-avatar" class="btn btn-danger plupload"
									  data-input-id="c-files"
									  data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp"
									  data-multiple="false" data-preview-id="p-collection_img"
									  data-url="qingdongams/base/upload"><i class="fa fa-upload"></i> 上传</button></span>

					</div>
					<span class="msg-box n-right" for="c-files"></span>
				</div>
				<ul class="row list-inline plupload-preview" id="p-collection_img"></ul>
			</div>
		</div>
	</div>

	<div class="form-group layer-footer">
		<label class="control-label col-xs-12 col-sm-2"></label>
		<div class="col-xs-12 col-sm-8">
			<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
			<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
		</div>
	</div>
</form>
<!--定义模板-->
<script type="text/html" id="testtpl">
	<dd>
		<div class="form-inline" style="margin-bottom:20px;display: flex;">
			<span>产品名称:<input type="text" data-source="qingdongams/common/getCustomerProduct"
							  class="form-control product selectpage" name="row[<%=name%>][<%=index%>][customer_product_id]"
							  data-field="name" data-primary-key="id" style="width: 300px;"
							  value="<%=row['customer_product_id']%>"/></span>

			<span style="margin-left: 10px"><span class="btn btn-sm btn-danger btn-remove"><i
					class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i
					class="fa fa-arrows"></i></span></span>
		</div>
	</dd>
</script>

<!--定义模板，模板语法使用Art-Template模板语法-->
<script type="text/html" id="testtpl2">
	<tr class="form-inline">
		<td>
			<input type="hidden" name="row[<%=name%>][<%=index%>][customer_product_id]" value="<%=row['customer_product_id']%>" >
			<div class="form-control" style="width: 90%">

				<a href="javascript:void(0)" class="select-product"
				   data-name="row[<%=name%>][<%=index%>][customer_product_id]"
				   data-url="qingdongams/customer/customer_product/index?isselect=1"  >
					<% if(row['product']){%>
					<%=row['product']['name']%>
					<% }else{%>
					【请点击选择】
					<% }%>
				</a>

			</div></td>

		<td style="width: 120px"><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></td>
	</tr>
</script>

<!--定义模板-->
<script type="text/html" id="parttpl">
	<tr class="form-inline">
		<td>
			<input type="hidden" name="row[<%=name%>][<%=index%>][id]" value="<%=row['id']%>" >
			<div class="form-control" style="width: 90%">

				<a href="javascript:void(0)" class="select-parts"
				   data-name="row[<%=name%>][<%=index%>][id]"
				   data-url="qingdongams/parts/parts/index?isselect=1"  >
					<% if(row['name']){%>
					<%=row['name']%>
					<% }else{%>
					【请点击选择】
					<% }%>
				</a>

			</div></td>
		<td style="width: 80px">
			<input type="number" name="row[<%=name%>][<%=index%>][number]" style="width: 80px"
				   class="form-control number" value="<% if(row['number']){%><%=row['number']%><% }else{%>1<% }%>" ></td>
		<td style="width: 120px"><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></td>
	</tr>
</script>

